package com.fanxuankai.boot.monitor.autoconfigure;

import com.fanxuankai.boot.monitor.MonitorTaskConfigurer;
import com.fanxuankai.commons.util.concurrent.ScheduledThreadPool;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * @author fanxuankai
 */
@EnableScheduling
@EnableConfigurationProperties({MonitorProperties.class})
@Import({MonitorTaskConfigurer.class})
public class MonitorAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public ScheduledThreadPoolExecutor scheduledThreadPoolExecutor() {
        return ScheduledThreadPool.INSTANCE.getExecutor();
    }
}
